package com.cxyzy.demo

import android.media.MediaPlayer
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class OriginalActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_original)
        playFromAssets("测试歌曲.wav")
    }

    private fun playFromAssets(fileName: String) {
        val fd = assets.openFd(fileName)
        val mediaPlayer = MediaPlayer()
        mediaPlayer.setDataSource(fd.fileDescriptor, fd.startOffset, fd.length)
        mediaPlayer.prepare()
        mediaPlayer.start()
    }
}
